package com.mljr.example.service;


import com.mljr.example.bean.PageContent;
import com.mljr.example.dao.PageContentDAO;

public class RefreshService {

	public static void  setNeedRefresh(Class clazz,boolean v){

		PageContentDAO pd = new PageContentDAO();
		if(v){
			pd.setPageContent(clazz.getName()+"_refresh","1");
		}else{
			pd.setPageContent(clazz.getName()+"_refresh","0");
		}


	}

	public static boolean ifNeedRefresh(Class clazz,boolean defaultV){
		boolean result = defaultV;
		PageContentDAO	pd = new PageContentDAO();
		PageContent pc = pd.getPageContent(clazz.getName()+"_refresh", PageContent.class);
		if(pc==null){
			return result;
		}else{
			if(pc.getValue().equals("1")){
				result =  true;
			}else{
				result =  false;
			}
			pd.deleteByProperties("key",clazz.getName()+"_refresh");
		}
		return  result;
	}


}
